/**
* eCommerce Application Sample for J2EE Training 
* Implementation of EcomCustomerBean
* @author Fabienne Boyer - Didier Donsez
* may 2006
*/

package beans.impl;

import javax.ejb.Remote;
import javax.ejb.SessionSynchronization;
import javax.ejb.Stateful;
import beans.EcomCustomerRemote;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 * Interface utilisateur
 * @author M2 MIAGE Apprentissage - Groupe 3
 */
@Stateful
@Remote(EcomCustomerRemote.class)
public class EcomCustomerBean implements EcomCustomerRemote{

    @PersistenceContext
    private EntityManager entityManager;

    public void createAccount(String accountId, String accountOwner, double balance) {
       AccountBean account = new AccountBean(accountId, accountOwner, balance);
       // todo ajouter dans la base
    }

    public double getAccountBalance(String accountId) {
        AccountBean accountBean = entityManager.find(AccountBean.class, accountId);
        return accountBean.getBalance();
    }

}
